<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

Route::get('think', function () {
    return 'hello,ThinkPHP6!';
});

Route::get('hello/:name', 'index/hello');

// 认证相关路由
Route::group('auth', function () {
    Route::post('login', 'Auth/login');
    Route::post('logout', 'Auth/logout');
    Route::post('refresh', 'Auth/refresh');
    Route::post('loginByPhone', 'Auth/loginByPhone');
    Route::post('registerByPhone', 'Auth/registerByPhone');
});

// 需要认证的路由组
Route::group('api', function () {
    // 这里添加需要认证的路由
})->middleware(\app\middleware\AuthMiddleware::class);

// 任务相关路由
Route::group('task', function () {
    // 创建任务
    Route::post('create', 'Task/create');
    
    // 搜索POI
    Route::get('search_poi', 'Task/searchPoi');
    
    // 获取POI详情
    Route::get('poi_detail', 'Task/getPoiDetail');
    
    // 更新POI信息
    Route::post('update_poi', 'Task/updatePoi');
    
    // 更新关键词和生成文案
    Route::post('update_script', 'Task/updateScript');
    
    // 更新视频URL
    Route::post('update_videos', 'Task/updateVideos');
    
    // 获取任务列表
    Route::get('list', 'Task/list');
    
    // 获取任务详情
    Route::get('detail', 'Task/detail');

    // 创建数字人视频任务
    Route::post('create_video_avatar_task', 'topview.Task/createVideoAvatarTask');
})->middleware(\app\middleware\AuthMiddleware::class);

// AiAvatar相关接口
Route::group('aiAvatar', function () {
    Route::get('aiavatarList', 'aiAvatar.Resource/aiavatarList');
    Route::get('voiceList', 'aiAvatar.Resource/voiceList');
    Route::get('audioList', 'aiAvatar.Resource/audioList');
    Route::get('getUploadCredential', 'aiAvatar.Resource/getUploadCredential');
    Route::post('videoAvatarSubmit', 'aiAvatar.Task/videoAvatarSubmit');
    Route::get('videoAvatarQuery', 'aiAvatar.Task/videoAvatarQuery');
    Route::get('videoAvatarList', 'aiAvatar.Task/videoAvatarList');
})->middleware(\app\middleware\AuthMiddleware::class);

// productAvatar相关接口
Route::get('productAvatar/categoryList', 'productAvatar.Resource/categoryList');
Route::get('productAvatar/publicAvatarList', 'productAvatar.Resource/publicAvatarList');
Route::post('productAvatar/replaceImageSubmit', 'productAvatar.Task/replaceImageSubmit');
Route::get('productAvatar/replaceImageQuery', 'productAvatar.Task/replaceImageQuery');
Route::post('productAvatar/image2videoSubmit', 'productAvatar.Task/image2videoSubmit');
Route::get('productAvatar/image2videoQuery', 'productAvatar.Task/image2videoQuery');

// 充值相关路由
Route::group('recharge', function () {
    Route::post('create_order', 'recharge.Recharge/createOrder');
    Route::get('query_order', 'recharge.Recharge/queryOrder');
    Route::get('get_order_list', 'recharge.Recharge/getOrderList');
    Route::get('check_order_status', 'recharge.Recharge/checkOrderStatus');
    Route::get('get_packages', 'recharge.Recharge/getPackages');
})->middleware(\app\middleware\AuthMiddleware::class);

Route::post('recharge/notify', 'recharge.Recharge/notify');

// marketingVideo相关接口（只保留存在的方法）
Route::get('productAvatar/avatarList', 'productAvatar.Resource/avatarList');

// M2V相关路由
Route::group('m2v', function () {
    Route::post('task/create', 'marketingVideo.M2v/createTask');
    Route::get('task/query', 'marketingVideo.M2v/queryTask');
    Route::get('task/list', 'marketingVideo.M2v/getTaskList');
})->middleware(\app\middleware\AuthMiddleware::class);

// 营销视频统一任务路由
Route::group('productAvatar', function () {
    // 资源接口
    Route::get('resource/avatarList', 'productAvatar.Resource/avatarList');
    
    // 任务接口
    Route::post('task/create', 'productAvatar.Task/createTask');
    Route::post('task/startVideoGeneration', 'productAvatar.Task/startVideoGeneration');
    Route::get('task/list', 'productAvatar.Task/getTaskList');
    Route::get('task/detail', 'productAvatar.Task/getTaskDetail');
    Route::get('task/replaceStatus', 'productAvatar.Task/getReplaceStatus');
    
    // 开发测试接口
    Route::get('task/checkReplaceStatus', 'productAvatar.Task/checkReplaceTaskStatus');
    Route::get('task/checkVideoStatus', 'productAvatar.Task/checkVideoTaskStatus');
})->middleware(\app\middleware\AuthMiddleware::class);

// 声音克隆相关路由
Route::group('voiceClone', function () {
    Route::post('submit', 'voice.VoiceClone/submit');
    Route::get('query', 'voice.VoiceClone/query');
    Route::get('list', 'voice.VoiceClone/list');
    Route::delete('delete', 'voice.VoiceClone/delete');
})->middleware(\app\middleware\AuthMiddleware::class);

// 文字转语音相关路由
Route::group('text2voice', function () {
    Route::post('submit', 'voice.Text2Voice/submit');
    Route::get('query', 'voice.Text2Voice/query');
    Route::get('list', 'voice.Text2Voice/list');
})->middleware(\app\middleware\AuthMiddleware::class);

// 积分相关路由
Route::group('points', function () {
    // 查询积分
    Route::get('balance', 'Points/getCurrentPoints');
    // 积分明细
    Route::get('logs', 'Points/getPointsLogs');
    // 积分统计
    Route::get('stats', 'Points/getPointsStats');
    // 创建充值订单
    Route::post('create_order', 'Points/createOrder');
    // 支付回调（这个可能需要单独处理，因为支付回调不需要认证）
    Route::post('pay_callback', 'Points/payCallback');
})->middleware(\app\middleware\AuthMiddleware::class);

// 人种相关路由
Route::group('ethnicity', function () {
    // 获取人种列表
    Route::get('list', 'EthnicityController/list');
    // 获取人种详情
    Route::get('detail', 'EthnicityController/detail');
    // 获取支持的场景列表
    Route::get('scenes', 'EthnicityController/scenes');
})->middleware(\app\middleware\AuthMiddleware::class);

// ProductAnyShoot模板相关路由
Route::group('productAnyShoot', function () {
    // 获取模板类目列表
    Route::get('template/category/list', 'productAnyShoot.Template/categoryList');
    // 获取模板列表
    Route::get('template/list', 'productAnyShoot.Template/templateList');
    
    // 任务相关
    Route::post('task/submit', 'productAnyShoot.Task/submitReplaceImageTask');
    Route::get('task/query', 'productAnyShoot.Task/queryReplaceImageTask');
    Route::get('task/list', 'productAnyShoot.Task/getUserTasks');
    Route::post('task/startImage2Video', 'productAnyShoot.Task/startImage2Video');
    // v2 product background 提交
    Route::post('product_background/task/submit', 'productAnyShoot.Task/submitProductBackgroundTask');
    // v2 product background 模板列表
    Route::get('product_background/template/list', 'productAnyShoot.ProductBackground/templateList');
    // v2 product background 一键提交（先去背景，后生成）
    Route::post('product_background/autoSubmit', 'productAnyShoot.ProductBackground/autoSubmit');
})->middleware(\app\middleware\AuthMiddleware::class);

// 字幕样式相关路由
Route::group('caption', function () {
    // 获取字幕样式列表
    Route::get('list', 'CaptionController/list');
})->middleware(\app\middleware\AuthMiddleware::class);

// Nanobanana相关路由
Route::group('nanobanana', function () {
    // 用户接口
    Route::post('textToImage', 'Nanobanana/textToImage'); // 文生图
    Route::post('imageToImage', 'Nanobanana/imageToImage'); // 图生图
    Route::get('list', 'Nanobanana/list'); // 获取生成列表
    Route::get('query', 'Nanobanana/query'); // 查询任务状态
    
    // 提示词预设
    Route::get('prompts', 'Nanobanana/getPrompts'); // 获取提示词列表
    Route::get('promptCategories', 'Nanobanana/getPromptCategories'); // 获取提示词分类
    
    // 管理接口（如果需要）
    Route::post('generate', 'Nanobanana/generate'); // 通用生成接口
})->middleware(\app\middleware\AuthMiddleware::class);

// Nanobanana回调接口（不需要认证，因为由外部API调用）
Route::post('nanobanana/callback', 'Nanobanana/callback');
Route::options('nanobanana/callback', 'Nanobanana/callback'); // 支持CORS预检请求
